package org.csu.assemblyroom.controller;

import org.csu.assemblyroom.common.CommonResponse;
import org.csu.assemblyroom.entity.Admin;
import org.csu.assemblyroom.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 管理员：登录+增删改查
 */
@Controller
@RequestMapping("/admin")
public class AdminController {
    @Autowired
    private AdminService adminService;

    @PostMapping("/login")
    @ResponseBody
    public CommonResponse<Admin> Login(@RequestParam String username,@RequestParam String password)
    {
        return adminService.login(username,password);
    }

    @PostMapping("/register")
    @ResponseBody
    public CommonResponse<Admin> Register(@RequestParam String username,@RequestParam String password,@RequestParam String repassword)
    {
        return adminService.register(username,password,repassword);
    }
}
